/**
 * COPYRIGHT HangZhou 99Cloud Technology Company Limited
 * All right reserved.
 */
package com.zfsmart.projectdemo.asset.controller;

import com.zfsmart.component.common.bean.restful.entity.RespMsg;
import com.zfsmart.component.feign.basefeign.AccountFeignUtil;
import com.zfsmart.component.feign.basefeign.OrderFeignUtil;
import com.zfsmart.projectdemo.asset.service.impl.Test;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description
 * @Author 薛铁琪
 * @CreateTime 2021/7/28 17:16
 * @Version 1.0
 */
@RestController
@RequestMapping("/asset")
@Api(value = "asset", tags = "asset")
@Slf4j
public class TestController {
    @Value("${test}")
    private String test;

    @Autowired
    OrderFeignUtil orderFeignUtil;
    @Autowired
    AccountFeignUtil accountFeignUtil;

    @Autowired
    Test testService;
    @Autowired
    Source source;

    @ApiOperation("doSomeThing")
    @GetMapping("/doSomeThing")
    public RespMsg doSomeThing() throws InterruptedException {
        testService.doSomeThing("xxxx");
        //Thread.sleep(30000);
        return RespMsg.success(test);
    }

    @ApiOperation("doSomeThing2")
    @GetMapping("/doSomeThing2")
    public RespMsg doSomeThing2() {
        testService.doSomeThing2("xxxx");
        return RespMsg.success(test);
    }

    @ApiOperation("doSomeThing3")
    @GetMapping("/doSomeThing3")
    public RespMsg doSomeThing3() {
        orderFeignUtil.test();
        return RespMsg.success(test);
    }


    @ApiOperation("doSomeThing4")
    @GetMapping("/doSomeThing4")
    public RespMsg doSomeThing4() throws InterruptedException {
        testService.doSomeThing3();
        return RespMsg.success(test);
    }

    @ApiOperation("doSomeThing5")
    @GetMapping("/doSomeThing5")
    public RespMsg doSomeThing5() throws InterruptedException {
        testService.doSomeThing4();
        return RespMsg.success(test);
    }

    @GetMapping("test-stream")
    public String testStream(){
        this.source.output().send(
                MessageBuilder.withPayload("消息！！").build()
        );
        return "success";
    }
}
